package cn.iocoder.yudao.module.jifenyuan.controller.app.roomlog;

import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomlog.RoomLogWithInfoDO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;

import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.jifenyuan.controller.app.roomlog.vo.*;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomlog.RoomLogDO;
import cn.iocoder.yudao.module.jifenyuan.convert.roomlog.RoomLogConvert;
import cn.iocoder.yudao.module.jifenyuan.service.roomlog.RoomLogService;

@Tag(name = "用户 APP - 记分员 房间记录")
@RestController
@RequestMapping("/jifenyuan/room-log")
@Validated
public class AppRoomLogController {

    @Resource
    private RoomLogService roomLogService;

//    @PostMapping("/create")
//    @Operation(summary = "创建记分员 房间记录")
//
//    public CommonResult<Long> createRoomLog(@Valid @RequestBody AppRoomLogCreateReqVO createReqVO) {
//        return success(roomLogService.createRoomLog(createReqVO));
//    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新记分员 房间记录")
//
//    public CommonResult<Boolean> updateRoomLog(@Valid @RequestBody AppRoomLogUpdateReqVO updateReqVO) {
//        roomLogService.updateRoomLog(updateReqVO);
//        return success(true);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除记分员 房间记录")
//    @Parameter(name = "id", description = "编号", required = true)
//
//    public CommonResult<Boolean> deleteRoomLog(@RequestParam("id") Long id) {
//        roomLogService.deleteRoomLog(id);
//        return success(true);
//    }
//
//    @GetMapping("/get")
//    @Operation(summary = "获得记分员 房间记录")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//
//    public CommonResult<AppRoomLogRespVO> getRoomLog(@RequestParam("id") Long id) {
//        RoomLogDO roomLog = roomLogService.getRoomLog(id);
//        return success(RoomLogConvert.INSTANCE.convert(roomLog));
//    }
//
//    @GetMapping("/list")
//    @Operation(summary = "获得记分员 房间记录列表")
//    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
//
//    public CommonResult<List<AppRoomLogRespVO>> getRoomLogList(@RequestParam("ids") Collection<Long> ids) {
//        List<RoomLogDO> list = roomLogService.getRoomLogList(ids);
//        return success(RoomLogConvert.INSTANCE.convertList(list));
//    }
//
//    @GetMapping("/page")
//    @Operation(summary = "获得记分员 房间记录分页")
//
//    public CommonResult<PageResult<AppRoomLogRespVO>> getRoomLogPage(@Valid AppRoomLogPageReqVO pageVO) {
//        PageResult<RoomLogDO> pageResult = roomLogService.getRoomLogPage(pageVO);
//        return success(RoomLogConvert.INSTANCE.convertPage(pageResult));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出记分员 房间记录 Excel")
//
//    @OperateLog(type = EXPORT)
//    public void exportRoomLogExcel(@Valid AppRoomLogExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<RoomLogDO> list = roomLogService.getRoomLogList(exportReqVO);
//        // 导出 Excel
//        List<AppRoomLogExcelVO> datas = RoomLogConvert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "记分员 房间记录.xls", "数据", AppRoomLogExcelVO.class, datas);
//    }


    @GetMapping("/getRoomLogByRoomId")
    @Operation(summary = "获得记分员 房间记录列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthenticated
    public CommonResult<List<AppRoomLogWithInfoRespVO>> getRoomLogByRoomId(@RequestParam("roomId") Long roomId) {
        List<RoomLogWithInfoDO> list = roomLogService.getRoomLogByRoomId(roomId);
        return success(RoomLogConvert.INSTANCE.convertList04(list));
    }


}
